//
// Created by jsjxsy on 2022/7/4.
//
#include <stdio.h>
#include <stdlib.h>
int cmpfunc(const void *a, const void *b) {
  return (*(int *) a - *(int *) b);
}


int values[] = { 88, 56, 100, 2, 25 };

int main(void) {
  int *item;
  int key = 32;

  /* 使用 bsearch() 在数组中查找值 32 */
  item = (int *) bsearch(&key, values, 5, sizeof(int), cmpfunc);
  if (item != NULL) {
    printf("Found item = %d\n", *item);
  } else {
    printf("Item = %d could not be found\n", *item);
  }
  return 0;
}
